package model.Settings;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

public abstract class Configurations {

	// Properties file names
	public static String BOARD_CONFIGURATIONS_FILENAME = "board.properties";
	public static String GAME_CONFIGURATIONS_FILENAME = "game.properties";
	
	// Properties
	public static String BOARD_SIZE_CONFIGURATION = "boardSize";

	protected Properties m_oProperties;
	
	/**
	 * Retrieve the configuration from the configuration file
	 * 
	 * @param a_sConfigurationFilename - configuration file name
	 * @throws FileNotFoundException
	 * @throws IOException
	 */
	public void loadConfiguration(String a_sConfigurationFilename) throws FileNotFoundException, IOException {
		m_oProperties.load(new FileInputStream(a_sConfigurationFilename));
	}
	
	/**
	 * Store new configuration into the configuration file
	 * 
	 * @param a_sConfigurationFilename - configuration file name
	 * @throws FileNotFoundException
	 * @throws IOException
	 */
	public void storeConfiguration(String a_sConfigurationFilename) throws FileNotFoundException, IOException {
		m_oProperties.store(new FileOutputStream(a_sConfigurationFilename),null);
	}
	
	/**
	 * Sets a configuration value
	 * 
	 * @param a_sConfigurationKey - the configuration key
	 * @param a_sConfigurationValue - the configuration value
	 */
	public void setConfigurationValue(String a_sConfigurationKey,String a_sConfigurationValue) {
		m_oProperties.setProperty(a_sConfigurationKey,a_sConfigurationValue);
	}
	
	/**
	 * Gets the configuration value
	 * 
	 * @param a_sConfigurationKey - the configuration key
	 * @return
	 */
	public String getConfigurationValue(String a_sConfigurationKey) {
		return m_oProperties.getProperty(a_sConfigurationKey);
	}
	
} // Configurations Class
